package com.yycwxt.modules.admin.user;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yycwxt.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Update("UPDATE sys_user SET code = #{code}, username = #{username} , type = #{type} WHERE id = #{id};")
    int update(String code, String username, String  type, Integer id);

    @Select("SELECT * FROM sys_user WHERE code = #{code} and password = md5(concat(salt,#{password}));")
    User selectByCode(@Param("code") String code, @Param("password") String password);

    @Update("UPDATE sys_user SET password = md5(concat(salt,#{password})) WHERE code = #{code} and username = #{username};")
    int updatePassword(String code, String username, String password);
}
